'use strict';

const { logger } = require('ee-core/log');
const {
    getMainWindow,
    restoreMainWindow,
    setCloseAndQuit,
    getCloseAndQuit
} = require('ee-core/electron/window');
const { electronApp } = require('ee-core/electron/app');

class AppTopWindowUtilsHandlerService {

    async utilClickHandler(args){
        logger.info('utilClickHandler --- > 触发顶部栏工具点击事件', args);
        let { action,flag } = args
        let mainWin = getMainWindow()
        switch (action) {
            case 'minimize':
                mainWin.minimize()
                break
            case 'maximize':
                let isMax = getMainWindow().isMaximized()
                if (isMax) {
                    mainWin.restore()
                }else {
                    mainWin.maximize()
                }
                break
            case 'close':
                mainWin.close()
                break
        }
    }
}

AppTopWindowUtilsHandlerService.toString = () => '[class AppTopWindowUtilsHandlerService]';

module.exports = {
    AppTopWindowUtilsHandlerService,
    appTopWindowUtilsHandlerService: new AppTopWindowUtilsHandlerService()
};